#include "ArmyState.h"
#include "BasicAI.h"
#include "params.h"

using namespace ArmyStateNS;

bool InitState::initialized = false;

void InitState::execute()
{
	LOG << "initializing" << endl;
	initialized = true;
	
	BasicAI *ai = BasicAI::instance();
	UserAPI &api = ai->get_api();

	for (int i = 0; i < (int) api.my_army.size(); ++i)
	{
		Army *army = api.my_army[i];
		GeneralType name = army->general->type;
#if 0		
		switch (army->soldierType)
		{
		case (SOLDIER_RANGER):
			ai->set_army_state(name, new OffensiveBattleState(name));
			break;
		case (SOLDIER_INFANTRY):
			abort();
			break;
		case (SOLDIER_CAVALRY):
			ai->set_army_state(name, new FastOccupyingState(name));
			break;
		}
#else
		if (army->numSoldier > 1000)
			ai->set_army_state(name, new OffensiveBattleState(name));
		else
			ai->set_army_state(name, new FastOccupyingState(name));
#endif
	}
	LOG << "initializing done" << endl;
}